package com.avic.rong.userOrder.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.avic.rong.R;
import com.avic.rong.userOrder.viewHolder.OrderListViewHolder;
import com.avic.rong.userOrder.bean.AllOrderListBean;

import java.util.List;

/**
 * Created by XinEr on 2019/7/17.
 * Describe:
 */
public class MineOrderListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private Context context;
    private List<AllOrderListBean.OrderListBean> listData;
    private String biaoZhunImg;
    private String fileServer;


    public String getFileServer() {
        return fileServer;
    }

    public void setFileServer(String fileServer) {
        this.fileServer = fileServer;
    }

    public String getBiaoZhunImg() {
        return biaoZhunImg;
    }

    public void setBiaoZhunImg(String biaoZhunImg) {
        this.biaoZhunImg = biaoZhunImg;
    }

    public MineOrderListAdapter(Context context, List<AllOrderListBean.OrderListBean> listData) {
        this.context = context;
        this.listData = listData;
    }

    public void clearData() {
        this.listData.clear();
    }

    public void setListData(List<AllOrderListBean.OrderListBean> listData) {
        this.listData.addAll(listData);
        notifyDataSetChanged();
    }

    public List<AllOrderListBean.OrderListBean> getListData() {
        return listData;
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.mine_order_list_item, viewGroup, false);

        return new OrderListViewHolder(inflate);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int i) {

        AllOrderListBean.OrderListBean orderListBean = listData.get(i);
        if (holder instanceof OrderListViewHolder) {
            ((OrderListViewHolder) holder).setData(orderListBean, context, getBiaoZhunImg(),getFileServer());
            holder.setIsRecyclable(false);
        }
    }

    @Override
    public int getItemCount() {
        return listData.size();
    }


}
